    /*
     * Bjorn Carandang
     * bac37@drexel.edu
     * CS338:GUI, Assignment [P3]
     */

/*
 * BasicClock.java
 *
 * Created on Aug 18, 2010, 9:24:46 PM
 */

package root;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;

/*
 * Some testbench clock that I made up in my spare time. I guess I'll just leave
 * it here for posterity.
 */
public class TestClocks extends javax.swing.JFrame {

    CasterClock internalClock;
    /** Creates new form BasicClock */
    public TestClocks(CasterClock c) {
        initComponents();
        internalClock = c;
        TickAction t = new TickAction();
        new Timer(500, t).start();
    }

    private TestClocks() {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    public void update(int shour, int sminute, int ssecond,
            int ehour, int eminute)
    {
        this.ServerHourLabel.setText(Integer.toString(shour));
        this.ServerMinuteLabel.setText(Integer.toString(sminute));
        this.ServerSecondsLabel.setText(Integer.toString(ssecond));
        this.ErinnHourLabel.setText(Integer.toString(ehour));
        this.ErinnMinuteLabel.setText(Integer.toString(eminute));
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        ServerHourLabel = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        ServerMinuteLabel = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        ServerSecondsLabel = new javax.swing.JLabel();
        ErinnHourLabel = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        ErinnMinuteLabel = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        ServerHourLabel.setText("jLabel1");

        jLabel2.setText(":");

        ServerMinuteLabel.setText("jLabel3");

        jLabel1.setText(":");

        ServerSecondsLabel.setText("jLabel3");

        ErinnHourLabel.setText("jLabel3");

        jLabel4.setText(":");

        ErinnMinuteLabel.setText("jLabel5");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(ServerHourLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(ServerMinuteLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(ServerSecondsLabel))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(ErinnHourLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(ErinnMinuteLabel)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ServerHourLabel)
                    .addComponent(jLabel2)
                    .addComponent(ServerMinuteLabel)
                    .addComponent(jLabel1)
                    .addComponent(ServerSecondsLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ErinnHourLabel)
                    .addComponent(jLabel4)
                    .addComponent(ErinnMinuteLabel))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    public class TickAction implements ActionListener{

        @Override
        public void actionPerformed(ActionEvent e) {
            update(
                    internalClock.getServerHour(),
                    internalClock.getServerMinute(),
                    internalClock.getServerSecond(),
                    internalClock.getErinnHour(),
                    internalClock.getErinnMinute()
                    );
            //System.out.println("Updated.");
        }
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel ErinnHourLabel;
    private javax.swing.JLabel ErinnMinuteLabel;
    private javax.swing.JLabel ServerHourLabel;
    private javax.swing.JLabel ServerMinuteLabel;
    private javax.swing.JLabel ServerSecondsLabel;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    // End of variables declaration//GEN-END:variables

}
